<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Mail;

class SendMail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $user_address;
    public $view;
    public $param;
    public $data;

    /**
     * SendMailTask constructor.
     * @param $user_address
     * @param $data ['view','param']
     */
    public function __construct($user_address, $data)
    {
        $this->data = $data;
        $this->user_address = $user_address;
        $this->view = $data['view'];
        $this->param = $data['param'];
    }
    public function handle()
    {
        file_put_contents(storage_path('logs').DIRECTORY_SEPARATOR.'debug.log',
            json_encode($this->data),FILE_APPEND);
//        Mail::to($this->user_address)->send(new $this->view($this->param));
    }
}
